﻿using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.IO;
using System.Linq;
using System.Configuration;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages;
using Microsoft.SharePoint.Utilities;
using System.Web.Security;
using System.Web.UI.HtmlControls;
using System.Web.Profile;
using System.Collections.Generic;
using System.Data;
using Microsoft.SharePoint.Administration;
using System.Text;

/*
Developed By: Sujeet Kumar
Developed On: 8th Aug 2011
Description: This code Creating a navigating a link construct using author and project title.
*/
namespace RDS.ResearchDataStore
{
    public partial class ResearchDataStoreUserControl : UserControl
    {
        string[] arryUrlCurrent;
        protected void Page_Load(object sender, EventArgs e)
        {
             GetProjectUsers();
        }

        /// <summary>
        /// Get User name and Login name
        /// </summary>
        public void GetProjectUsers()
        {
            Microsoft.SharePoint.SPWeb webSite = Microsoft.SharePoint.SPContext.Current.Web;
            //get the loginname on sharepoint site 
            string userName = webSite.CurrentUser.LoginName.ToString();
            userName = userName.Replace("i:0#.w|sharepoint\\", "");
            StringBuilder url = new StringBuilder();
            String projectUrl = string.Empty;
            SPSite spSite = SPContext.Current.Site; //get the current site
            string urlCurrent = spSite.Url; //get the web site url
            arryUrlCurrent = urlCurrent.Split(new char[] { '/' }); // Split the Url On Base of "/" //
            int count;
            for (count = 4; count < arryUrlCurrent.Length; count++)
            {
                url.Append(arryUrlCurrent[count].ToString());   //get the URL //
            }
            projectUrl = url.ToString().Substring(1, url.Length - 1);
            //hlkUrl.NavigateUrl = "//rdprojects.latrobe.edu.au/projects/" + userName + "-" + url;
           hlkUrl.NavigateUrl = @"\\s5\RDS";
           // hlkUrl.NavigateUrl = @"\\s4\RDS";
            hlkUrl.Text = "//rdprojects.latrobe.edu.au/projects/" + userName + "-" + url;
        }
    }
}
